<%@ page language="java" contentType="text/html; charset=UTF-8" pageEncoding="UTF-8" %>
<%@ include file="/include/taglibs.jsp" %>
<html>
<head>
    <%@include file="/include/header.html" %>
    <script type="text/javascript" src="${ctx}/appjs/elec/elecPile.js"></script>
</head>

<script type="text/javascript">
    $('#topLink', window.parent.document).html(function (i, origText) {
        return '<ol class="breadcrumb">' +
            '<li class="breadcrumb-item">' +
            '<a href="">主页</a>' +
            '</li>' +
            '<li class="breadcrumb-item">' +
            '<a>设备管理</a>' +
            '</li>' +
            '<li class="breadcrumb-item">' +
            '<strong>编辑桩信息</strong>' +
            '</li>' +
            '<li class="breadcrumb-item">' +
            '<a href="javascript:window.history.back()"><i class="fa fa-times"></i> 返回</a>' +
            '</li>' +
            '</ol>';
    });

</script>

<body class="gray-bg">
<div class="wrapper wrapper-content ">
    <div class="row">
        <div class="col-sm-12">
            <div class="ibox float-e-margins">
                <div class="ibox-title">
                    <div class="columns pull-left">
                        <h5 class="font-bold">编辑桩信息</h5>
                    </div>
                    <div class="ibox-tools">
                        <a class="close-link">
                            <i class="fa fa-times"></i>
                        </a>
                    </div>
                </div>

                <div class="ibox-content">
                    <form class="form-horizontal m-t" id="addElecPile">
                        <input name="elecPileId" id="elecPileId" value="${elecPile.elecPileId}" type="hidden">
                        <%--<input name="elecStationId" id="elecStationId" value="${elecPile.elecStationId}" type="hidden">--%>
                        <div class="form-group row">
                            <label class="col-sm-3 col-form-label text-right">桩编号：</label>
                            <div class="col-sm-8">
                                <input type="text" class="form-control" readonly
                                       value="${elecPile.pileNo}">
                            </div>
                        </div>
                        <div class="form-group row">
                            <label class="col-sm-3 col-form-label text-right">桩名称：</label>
                            <div class="col-sm-8">
                                <input type="text" class="form-control" id="pileSort" name="pileSort"
                                       value="${elecPile.pileSort}">
                            </div>
                        </div>
                        <div class="form-group row">
                            <label class="col-sm-3 col-form-label text-right">充电类型：</label>
                            <div class="col-sm-8">
                                <select class="form-control" name="pileElecType" id="pileElecType">
                                    <option value="6"
                                            <c:if test="${elecPile.pileElecType == 6}">selected</c:if>   >快充
                                    </option>
                                    <option value="7"
                                            <c:if test="${elecPile.pileElecType == 7}">selected</c:if>   >慢充
                                    </option>
                                </select>
                            </div>
                        </div>
                        <div class="form-group row">
                            <label class="col-sm-3 col-form-label text-right">所属站点：</label>
                            <div class="col-sm-8">
                                <select name="elecStationId" id="elecStationId" class="form-control"  onchange="loadOperator(this.value)">
                                    <c:forEach items="${stations}" var="stationInfo">
                                        <option value="${stationInfo.elecStationId}"
                                                <c:if test="${stationInfo.elecStationId == elecPile.elecStationId}">selected</c:if>
                                        >${stationInfo.stationName}</option>
                                    </c:forEach>
                                </select>
                            </div>
                        </div>
                        <div class="form-group row">
                            <label class="col-sm-3 col-form-label text-right">所属加盟商：</label>
                            <div class="col-sm-8">
                                <select name="operatorId" id="operatorId" class="form-control" disabled>
                                    <c:forEach items="${operators}" var="operatorInfo">
                                        <option value="${operatorInfo.operatorId}"
                                                <c:if test="${operatorInfo.operatorId == elecPile.operatorId}">selected</c:if>
                                        >${operatorInfo.operatorName}</option>
                                    </c:forEach>
                                </select>
                            </div>
                        </div>
                        <div class="form-group row">
                            <label class="col-sm-3 col-form-label text-right">投运状态：</label>
                            <div class="col-sm-8">
                                <select class="form-control" id="operateStatus" name="operateStatus">
                                    <option value="0"
                                            <c:if test="${elecPile.operateStatus eq '0'}">selected</c:if>   >未上线
                                    </option>
                                    <option value="1"
                                            <c:if test="${elecPile.operateStatus eq '1'}">selected</c:if>   >上线
                                    </option>
                                    <option value="2"
                                            <c:if test="${elecPile.operateStatus eq '2'}">selected</c:if>   >下线
                                    </option>
                                    <option value="3"
                                            <c:if test="${elecPile.operateStatus eq '3'}">selected</c:if>   >故障
                                    </option>
                                </select>
                            </div>
                        </div>
                        <div class="form-group row">
                            <label class="col-sm-3 col-form-label text-right">电桩型号：</label>
                            <div class="col-sm-8">
                                <input type="text" class="form-control" id="equipmentModel" name="equipmentModel"
                                       value="${elecPile.equipmentModel}">
                            </div>
                        </div>
                        <div class="form-group row">
                            <label class="col-sm-3 col-form-label text-right">额定输出功率 单位(kw)：</label>
                            <div class="col-sm-8">
                                <input type="text" class="form-control" id="power" name="power"
                                       value="${elecPile.power}">
                            </div>
                        </div>
                        <div class="form-group row">
                            <label class="col-sm-3 col-form-label text-right">设备生产商：</label>
                            <div class="col-sm-8">
                                <input type="text" class="form-control" id="hlhtManufacturerName" name="hlhtManufacturerName"
                                       value="${elecPile.hlhtManufacturerName}">
                            </div>
                        </div>
                        <div class="form-group row">
                            <label class="col-sm-3 col-form-label text-right">出厂编号：</label>
                            <div class="col-sm-8">
                                <input type="text" class="form-control" id="hlhtManufacturerId" name="hlhtManufacturerId"
                                       value="${elecPile.hlhtManufacturerId}">
                            </div>
                        </div>
                        <div class="form-group row">
                            <label class="col-sm-3 col-form-label text-right">设备生产日期：</label>
                            <div class="col-sm-8">
                                <input type="text" class="form-control" id="productionDate" name="productionDate"
                                       value="${elecPile.productionDate}">
                            </div>
                        </div>
                        <div class="form-group row">
                            <label class="col-sm-3 col-form-label text-right">备注说明：</label>
                            <div class="col-sm-8">
                                <input type="text" class="form-control" id="remark" name="remark"
                                       value="${elecPile.remark}">
                            </div>
                        </div>
                        <div class="form-group">
                            <div class="col-sm-3 col-sm-offset-8 text-right">
                                <button type="submit" class="btn btn-primary">提交</button>
                            </div>
                        </div>
                    </form>
                </div>
            </div>
        </div>
    </div>
</div>
<script type="text/javascript">
    layui.use('laydate', function () {
        var laydate = layui.laydate;
        var logoutTime = laydate.render({
            elem: '#logoutTime',
            type: 'datetime',
            format: 'yyyy-MM-dd HH:mm:ss',
            trigger: 'click'
        });

        var productionDate = laydate.render({
            elem: '#productionDate',
            type: 'date',
            format: 'yyyy-MM-dd',
            trigger: 'click'
        });
    });
    function loadOperator(_id){

        $("#operatorId").html("");
        /*$('#operatorId' option:first').prop('selected','selected');
        $('#operatorId').trigger('change.select2');*/
        $.ajax({
            url: prefix + "/loadOperator",
            type: "get",
            data: {
                elecStationId:_id
            },
            success: function (data) {
                debugger
                if (data!=null) {
                    // $("#operatorId").text(data.operatorId);
                    var str = "<option value=" + data.operatorId + " selected='selected'>" + data.operatorName + "</option>";
                    $("#operatorId").append(str);
                }
            }
        });
    }

    addElecPile.init();
</script>
</body>
</html>
